#ifndef __SHADER_H__
#define __SHADER_H__

#include "../Common.h"
#include "Utils/Depot.h"
#include "Renderer.h"

namespace RayFrame
{
  class ShaderProgram;

  /// Shader base class
  class DLL_DECLARE Shader: public IObject
  {
  public:
    typedef enum _SHADER_TYPE
    {
      VERTEX_SHADER,
      PIXEL_SHADER,
    } ShaderType;

    typedef enum _SHAER_ERROR
    {
      SHADER_NO_ERROR,
      SHADER_FILE_NOT_FOUND,
      SHADER_EMPTY_FILE,
      SHADER_NO_MEMORY,
      SHADER_ERROR_COUNT,
    } ShaderError;
  protected:
    friend class ShaderProgram;
    friend class Renderer;

    ShaderProgram* m_program;
    STRING        m_source;
    STRING        m_filename;
    STRING        m_log;
    ShaderType    m_type;
  protected:
    ShaderError loadShader();
    int unloadShader();

  public:
    Shader()
    {
      m_program = NULL;
    };

    virtual ~Shader();

    STRING GetLog(){ return m_log; };

    virtual void Create(STRING filename);
    virtual void Destroy();

    void SetShaderType(ShaderType s){ m_type = s; };
    ShaderType GetShaderType(){ return m_type; };
  };

  DECL_BUCKET_TYPE(ShaderBucket, Shader);
}

#endif